package cn.cdeden.knowledge.controller.invitation;

import cn.cdeden.common.core.domain.R;
import cn.cdeden.common.core.utils.page.TableDataInfo;
import cn.cdeden.knowledge.domain.dto.UserSynergyQueryParam;
import cn.cdeden.knowledge.domain.vo.FilesSynergyVo;
import cn.cdeden.knowledge.utils.FilesSynergyUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 协同编辑:协同空间
 */
@RestController
@RequiredArgsConstructor
//@Api(tags = "协同编辑:协同空间")
@RequestMapping("/api/synergy/url")
public class UserSynergyController {


    private final FilesSynergyUtils utils;

    /**
     * 协同编辑:查询协同空间列表
     * @param query
     * @param pageable
     * @return
     */
    @GetMapping("/list")
//    @Log("协同编辑:查询协同空间列表")
//    @ApiOperation("协同编辑:查询协同空间列表")
    public R<TableDataInfo<FilesSynergyVo>> queryUserInfo(UserSynergyQueryParam query, Pageable pageable){
        TableDataInfo<FilesSynergyVo> pageInfo = utils.queryUserInfo(query, pageable);
        return R.ok(pageInfo);
    }

    /**
     * 协同编辑:取消协同空间
     * @param infoDto
     * @return
     */
    @PostMapping("/deleteUsers")
//    @Log("协同编辑:取消协同空间")
//    @ApiOperation("协同编辑:取消协同空间")
    @Transactional(rollbackFor = Exception.class)
    public R<FilesSynergyVo> deleteUserInfos(@RequestBody List<String> infoDto){
        for (String id : infoDto) {
            boolean b = utils.deleteUserInfo(id);
        }

        return R.ok();
    }


}
